using System;

namespace SJBotGame
{
	public class PointRange
	{
		private Point point1;
		public Point Point1 { get { return point1; } set { point1 = value; } }
		//
		private Point point2;
		public Point Point2 { get { return point2; } set { point2 = value; } }
		//		
		public PointRange (Point point1, Point point2)
		{
			this.point1 = point1;
			this.point2 = point2;
		}
		public PointRange (Point point1)
		{
			this.point1 = point1;
			this.point2 = point1;
		}
		public override string ToString ()
		{
			return string.Format ("[PointRange: Point1={0}, Point2={1}]", Point1, Point2);
		}
        //
        public Point[] GetPoints()
        {
            int size = (Math.Abs(point1.X - point2.X) + 1) * (Math.Abs(point1.Y - point2.Y) + 1);
            Point[] points = new Point [size];
            int xMin = Math.Min(point1.X, point2.X);
            int yMin = Math.Min(point1.Y, point2.Y);
            int xMax = Math.Max(point1.X, point2.X);
            int yMax = Math.Max(point1.Y, point2.Y);
            int k = 0;
            for (int i = xMin; i <= xMax; i++)
            {
                for (int j = yMin; j <= yMax; j++)
                {
                    points[k] = new Point(i, j);
                    k++;
                }
            }
            return points;
        }
	}
}

